home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Dev / misc / WHDLoad_dev.lha / WHDLoad / Include / whdload.i < prev    next >
Encoding:
Text File  |  2003-08-07  |  21.8 KB  |  707 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Module.    whdload.i
  3. ;  :Contens.    include file for WHDLoad and Slaves
  4. ;  :Author.    Bert Jahn
  5. ;  :EMail.    wepl@whdload.de
  6. ;  :Address.    Feodorstraße 8, Zwickau, 08058, Germany
  7. ;  :Version.    $Id: whdload.i 16.0 2003/08/04 21:20:08 wepl Exp wepl $
  8. ;  :History.    11.04.99 marcos moved to separate include file
  9. ;        08.05.99 resload_Patch added
  10. ;        09.03.00 new stuff for whdload v11
  11. ;        10.07.00 new stuff for whdload v12
  12. ;        25.11.00 new stuff for whdload v13
  13. ;        13.01.01 some comments spelling errors fixed
  14. ;        15.03.01 v14 stuff added
  15. ;        15.04.01 FAILMSG added
  16. ;        29.04.01 resload_Relocate tags added
  17. ;        09.12.01 v15 stuff added
  18. ;        20.08.02 WHDLTAG_ALIGN added
  19. ;        19.11.02 WHDLTAG_CHKCOPCON added
  20. ;        03.06.03 EmulDivZero added
  21. ;        16.06.03 new PL's added
  22. ;        18.07.03 EmulIllegal added
  23. ;  :Copyright.    © 1996-2002 Bert Jahn, All Rights Reserved
  24. ;  :Language.    68000 Assembler
  25. ;  :Translator.    Barfly 2.9, Asm-Pro 1.16, PhxAss 4.38
  26. ;---------------------------------------------------------------------------*
  27.  
  28.  IFND WHDLOAD_I
  29. WHDLOAD_I=1
  30.  
  31.     IFND    EXEC_EXECBASE_I
  32.     INCLUDE    exec/execbase.i
  33.     ENDC
  34.     IFND    EXEC_TYPES_I
  35.     INCLUDE    exec/types.i
  36.     ENDC
  37.     IFND    GRAPHICS_MODEID_I
  38.     INCLUDE    graphics/modeid.i
  39.     ENDC
  40.     IFND    UTILITY_TAGITEM_I
  41.     INCLUDE    utility/tagitem.i
  42.     ENDC
  43.  
  44. ;=============================================================================
  45. ;    misc
  46. ;=============================================================================
  47.  
  48. SLAVE_HEADER    MACRO
  49.         moveq    #-1,d0
  50.         rts
  51.         dc.b    "WHDLOADS"
  52.         ENDM
  53.  
  54. ;=============================================================================
  55. ;    return-values for termination (resload_Abort)
  56. ;=============================================================================
  57.  
  58. TDREASON_OK        = -1    ;normal termination
  59. TDREASON_DOSREAD    = 1    ;error caused by resload_ReadFile
  60.                 ; primary   = dos errorcode
  61.                 ; secondary = file name
  62. TDREASON_DOSWRITE    = 2    ;error caused by resload_SaveFile or
  63.                 ;resload_SaveFileOffset
  64.                 ; primary   = dos errorcode
  65.                 ; secondary = file name
  66. TDREASON_DEBUG        = 5    ;cause WHDLoad to make a coredump and quit
  67.                 ; primary   = PC (writing to dump files)
  68.                 ; secondary = SR (writing to dump files)
  69. TDREASON_DOSLIST    = 6    ;error caused by resload_ListFiles
  70.                 ; primary   = dos errorcode
  71.                 ; secondary = directory name
  72. TDREASON_DISKLOAD    = 7    ;error caused by resload_DiskLoad
  73.                 ; primary   = dos errorcode
  74.                 ; secondary = disk number
  75. TDREASON_DISKLOADDEV    = 8    ;error caused by resload_DiskLoadDev
  76.                 ; primary   = trackdisk errorcode
  77. TDREASON_WRONGVER    = 9    ;an version check (e.g. crc16) has detected an
  78.                 ;unsupported version of the installed program
  79. TDREASON_OSEMUFAIL    = 10    ;error in the OS emulation module
  80.                 ; primary   = subsystem (e.g. "exec.library")
  81.                 ; secondary = error number (e.g. _LVOAllocMem)
  82. ; version 7
  83. TDREASON_REQ68020    = 11    ;installed program requires a MC68020
  84. TDREASON_REQAGA        = 12    ;installed program requires the AGA chip set
  85. TDREASON_MUSTNTSC    = 13    ;installed program needs NTSC videomode to run
  86. TDREASON_MUSTPAL    = 14    ;installed program needs PAL videomode to run
  87. ; version 8
  88. TDREASON_MUSTREG    = 15    ;WHDLoad must be registered
  89. TDREASON_DELETEFILE    = 27    ;error caused by resload_DeleteFile
  90.                 ; primary   = dos errorcode
  91.                 ; secondary = file name
  92. ; version 14.1
  93. TDREASON_FAILMSG    = 43    ;failure with variable message text
  94.                 ; primary   = text
  95.  
  96. ;=============================================================================
  97. ; tagitems for the resload_Control function
  98. ;=============================================================================
  99.  
  100.  ENUM    TAG_USER+$8000000
  101.  EITEM    WHDLTAG_ATTNFLAGS_GET    ;get info about current CPU/FPU/MMU
  102.  EITEM    WHDLTAG_ECLOCKFREQ_GET    ;get frequency custom chips operate on
  103.  EITEM    WHDLTAG_MONITOR_GET    ;get the used monitor/video mode
  104.                 ;(NTSC_MONITOR_ID or PAL_MONITOR_ID)
  105.  EITEM    WHDLTAG_Private1
  106.  EITEM    WHDLTAG_Private2
  107.  EITEM    WHDLTAG_Private3
  108.  EITEM    WHDLTAG_BUTTONWAIT_GET    ;get value of WHDLoad option ButtonWait/S (0/-1)
  109.  EITEM    WHDLTAG_CUSTOM1_GET    ;get value of WHDLoad option Custom1/N (integer)
  110.  EITEM    WHDLTAG_CUSTOM2_GET    ;get value of WHDLoad option Custom2/N (integer)
  111.  EITEM    WHDLTAG_CUSTOM3_GET    ;get value of WHDLoad option Custom3/N (integer)
  112.  EITEM    WHDLTAG_CUSTOM4_GET    ;get value of WHDLoad option Custom4/N (integer)
  113.  EITEM    WHDLTAG_CUSTOM5_GET    ;get value of WHDLoad option Custom5/N (integer)
  114. ; version 7
  115.  EITEM    WHDLTAG_CBSWITCH_SET    ;set a function to be executed during switch
  116.                 ;from operating system to installed program
  117.  EITEM    WHDLTAG_CHIPREVBITS_GET    ;get info about current custom chip set
  118. ; version 8
  119.  EITEM    WHDLTAG_IOERR_GET    ;get last dos errorcode
  120.  EITEM    WHDLTAG_Private4
  121. ; version 9
  122.  EITEM    WHDLTAG_CBAF_SET    ;set a function to be executed when an access
  123.                 ;fault exception occurs
  124.  EITEM    WHDLTAG_VERSION_GET    ;get WHDLoad major version number
  125.  EITEM    WHDLTAG_REVISION_GET    ;get WHDLoad minor version number
  126.  EITEM    WHDLTAG_BUILD_GET    ;get WHDLoad build number
  127.  EITEM    WHDLTAG_TIME_GET    ;get current time and date
  128. ; version 11
  129.  EITEM    WHDLTAG_BPLCON0_GET    ;get system bplcon0
  130. ; version 12
  131.  EITEM    WHDLTAG_KEYTRANS_GET    ;get pointer to a 128 byte table to convert
  132.                 ;rawkey's to ascii-chars
  133. ; version 13
  134.  EITEM    WHDLTAG_CHKBLTWAIT    ;enable/disable blitter wait check
  135.  EITEM    WHDLTAG_CHKBLTSIZE    ;enable/disable blitter size check
  136.  EITEM    WHDLTAG_CHKBLTHOG    ;enable/disable dmacon.blithog (bltpri) check
  137.  EITEM    WHDLTAG_CHKCOLBST    ;enable/disable bplcon0.color check
  138. ; version 14
  139.  EITEM    WHDLTAG_LANG_GET    ;GetLanguageSelection like lowlevel.library
  140. ; version 14.5
  141.  EITEM    WHDLTAG_DBGADR_SET    ;set debug base address
  142. ; version 15
  143.  EITEM    WHDLTAG_DBGSEG_SET    ;set debug base segment address (BPTR!)
  144. ; version 15.2
  145.  EITEM    WHDLTAG_CHKCOPCON    ;enable/disable copcon check
  146.  EITEM    WHDLTAG_Private5    ;allows setting WCPU_Base_CB using SetCPU
  147.  
  148. ;=============================================================================
  149. ; tagitems for the resload_Relocate function
  150. ;=============================================================================
  151.  
  152. ; version 14.1
  153.  ENUM    TAG_USER+$8100000
  154.  EITEM    WHDLTAG_CHIPPTR        ;relocate MEMF_CHIP hunks to this address
  155.  EITEM    WHDLTAG_FASTPTR        ;relocate MEMF_FAST hunks to this address
  156. ; version 15.1
  157.  EITEM    WHDLTAG_ALIGN        ;round up hunk lengths to the given boundary
  158.  
  159. ;=============================================================================
  160. ; tagitems for the resload_DiskLoadDev function
  161. ;=============================================================================
  162.  
  163. ; version 16.0
  164.  ENUM    TAG_USER+$8200000
  165.  EITEM    WHDLTAG_TDUNIT        ;unit of trackdisk.device to use
  166.  
  167. ;=============================================================================
  168. ;    structure returned by WHDLTAG_TIME_GET
  169. ;=============================================================================
  170.  
  171.     STRUCTURE whdload_time,0
  172.         ULONG    whdlt_days    ;days since 1.1.1978
  173.         ULONG    whdlt_mins    ;minutes since last day
  174.         ULONG    whdlt_ticks    ;1/50 seconds since last minute
  175.         UBYTE    whdlt_year    ;78..77 (1978..2077)
  176.         UBYTE    whdlt_month    ;1..12
  177.         UBYTE    whdlt_day    ;1..31
  178.         UBYTE    whdlt_hour    ;0..23
  179.         UBYTE    whdlt_min    ;0..59
  180.         UBYTE    whdlt_sec    ;0..59
  181.         LABEL    whdlt_SIZEOF
  182.  
  183. ;=============================================================================
  184. ; Slave        Version 1..3
  185. ;=============================================================================
  186.  
  187.     STRUCTURE    WHDLoadSlave,0
  188.     STRUCT    ws_Security,4
  189.     STRUCT    ws_ID,8        ;"WHDLOADS"
  190.     UWORD    ws_Version    ;required WHDLoad version
  191.     UWORD    ws_Flags    ;see below
  192.     ULONG    ws_BaseMemSize    ;size of required memory (multiple of $1000)
  193.     ULONG    ws_ExecInstall    ;must be 0
  194.     RPTR    ws_GameLoader    ;Slave code, called by WHDLoad
  195.     RPTR    ws_CurrentDir    ;subdirectory for data files
  196.     RPTR    ws_DontCache    ;pattern for files not to cache
  197.  
  198. ;=============================================================================
  199. ; additional    Version 4..7
  200. ;=============================================================================
  201.  
  202.     UBYTE    ws_keydebug    ;raw key code to quit with debug
  203.                 ;works only if vbr is moved !
  204.                 ;=0 means no key
  205.     UBYTE    ws_keyexit    ;raw key code to exit
  206.                 ;works only if vbr is moved !
  207.                 ;=0 means no key
  208.  
  209. ;=============================================================================
  210. ; additional    Version 8..9
  211. ;=============================================================================
  212.  
  213.     ULONG    ws_ExpMem    ;size of required expansions memory, during
  214.                 ;initialisation overwritten by WHDLoad with
  215.                 ;address of the memory (multiple of $1000)
  216.                 ;if negative it is optional
  217.  
  218. ;=============================================================================
  219. ; additional    Version 10..15
  220. ;=============================================================================
  221.  
  222.     RPTR    ws_name        ;name of the installed program
  223.     RPTR    ws_copy        ;year and owner of the copyright
  224.     RPTR    ws_info        ;additional informations (author, version...)
  225.  
  226. ;=============================================================================
  227. ; additional    Version 16
  228. ;=============================================================================
  229.  
  230.     RPTR    ws_kickname    ;name of kickstart image
  231.     ULONG    ws_kicksize    ;size of kickstart image
  232.     UWORD    ws_kickcrc    ;crc16 of kickstart image
  233.     LABEL    ws_SIZEOF
  234.  
  235. ;=============================================================================
  236. ; Flags for ws_Flags
  237. ;=============================================================================
  238.  
  239.     BITDEF WHDL,Disk,0    ;means diskimages are used by the Slave
  240.                 ;starting WHDLoad 0.107 obsolete
  241.     BITDEF WHDL,NoError,1    ;forces WHDLoad to abort the installed program
  242.                 ;if error during resload_#? function occurs
  243.     BITDEF WHDL,EmulTrap,2    ;forward "trap #n" exceptions to the handler
  244.                 ;of the installed program
  245.     BITDEF WHDL,NoDivZero,3    ;ignore division by zero exceptions
  246. ; version 7
  247.     BITDEF WHDL,Req68020,4    ;abort if no MC68020 or better is available
  248.     BITDEF WHDL,ReqAGA,5    ;abort if no AGA chipset is available
  249. ; version 8
  250.     BITDEF WHDL,NoKbd,6    ;says WHDLoad that it doesn't should get the
  251.                 ;keycode from the keyboard in conjunction with
  252.                 ;NoVBRMove, must be used if the installed
  253.                 ;program checks the keyboard from the VBI
  254.     BITDEF WHDL,EmulLineA,7    ;forward "line-a" exceptions to the handler
  255.                 ;of the installed program
  256. ; version 9
  257.     BITDEF WHDL,EmulTrapV,8    ;forward "trapv" exceptions to the handler
  258.                 ;of the installed program
  259. ; version 11
  260.     BITDEF WHDL,EmulChk,9    ;forward "chk, chk2" exceptions to the handler
  261.                 ;of the installed program
  262.     BITDEF WHDL,EmulPriv,10    ;forward 'privilege violation' exceptions to
  263.                 ;the handler of the installed program
  264. ; version 12
  265.     BITDEF WHDL,EmulLineF,11 ;forward "line-f" exceptions to the handler
  266.                 ;of the installed program
  267. ; version 13
  268.     BITDEF WHDL,ClearMem,12    ;initialize BaseMem and ExpMem with 0
  269. ; version 15
  270.     BITDEF WHDL,Examine,13    ;preload cache for Examine/ExNext
  271. ; version 16
  272.     BITDEF WHDL,EmulDivZero,14 ;forward "division by zero" exceptions to
  273.                 ;the handler of the installed program
  274.     BITDEF WHDL,EmulIllegal,15 ;forward "illegal instruction" exceptions to
  275.                 ;the handler of the installed program
  276.  
  277. ;=============================================================================
  278. ; properties for resload_SetCPU
  279. ;=============================================================================
  280.  
  281. WCPUF_Base    = 3        ;BaseMem mask
  282. WCPUF_Base_NCS    = 0        ;BaseMem = non cacheable serialized
  283. WCPUF_Base_NC    = 1        ;BaseMem = non cacheable
  284. WCPUF_Base_WT    = 2        ;BaseMem = cacheable write through
  285. WCPUF_Base_CB    = 3        ;BaseMem = cacheable copyback
  286. WCPUF_Exp    = 12        ;ExpMem mask
  287. WCPUF_Exp_NCS    = 0        ;ExpMem = non cacheable serialized
  288. WCPUF_Exp_NC    = 4        ;ExpMem = non cacheable
  289. WCPUF_Exp_WT    = 8        ;ExpMem = cacheable write through
  290. WCPUF_Exp_CB    = 12        ;ExpMem = cacheable copyback
  291. WCPUF_Slave    = 48        ;Slave mask
  292. WCPUF_Slave_NCS    = 0        ;Slave = non cacheable serialized
  293. WCPUF_Slave_NC    = 16        ;Slave = non cacheable
  294. WCPUF_Slave_WT    = 32        ;Slave = cacheable write through
  295. WCPUF_Slave_CB    = 48        ;Slave = cacheable copyback
  296.  
  297.     BITDEF WCPU,IC,8    ;instruction cache (20-60)
  298.     BITDEF WCPU,DC,9    ;data cache (30-60)
  299.     BITDEF WCPU,NWA,10    ;disable write allocation (30)
  300.     BITDEF WCPU,SB,11    ;store buffer (60)
  301.     BITDEF WCPU,BC,12    ;branch cache (60)
  302.     BITDEF WCPU,SS,13    ;superscalar dispatch (60)
  303.     BITDEF WCPU,FPU,14    ;enable fpu (60)
  304.  
  305. WCPUF_All    = WCPUF_Base!WCPUF_Exp!WCPUF_Slave!WCPUF_IC!WCPUF_DC!WCPUF_NWA!WCPUF_SB!WCPUF_BC!WCPUF_SS!WCPUF_FPU
  306.  
  307. ;=============================================================================
  308. ; resload_#? functions
  309. ; a JMP-tower inside WHDLoad (similar to a library)
  310. ; base is given on startup via A0
  311. ;=============================================================================
  312.  
  313.     STRUCTURE    ResidentLoader,0
  314.     ULONG    resload_Install        ;private
  315.     ULONG    resload_Abort
  316.         ; return to operating system
  317.         ; IN: (a7) = ULONG  reason for aborting
  318.         ;   (4,a7) = ULONG  primary error code
  319.         ;   (8,a7) = ULONG  secondary error code
  320.         ; ATTENTION this routine must called via JMP! (not JSR)
  321.     ULONG    resload_LoadFile
  322.         ; load file to memory
  323.         ; IN :    a0 = CSTR   filename
  324.         ;    a1 = APTR   address
  325.         ; OUT :    d0 = ULONG  success (size of file)
  326.         ;    d1 = ULONG  dos errorcode
  327.     ULONG    resload_SaveFile
  328.         ; write memory to file
  329.         ; IN :    d0 = ULONG  size
  330.         ;    a0 = CSTR   filename
  331.         ;    a1 = APTR   address
  332.         ; OUT :    d0 = BOOL   success
  333.         ;    d1 = ULONG  dos errorcode
  334.     ULONG    resload_SetCACR
  335.         ; set cachebility for BaseMem
  336.         ; IN :    d0 = ULONG  new setup
  337.         ;    d1 = ULONG  mask
  338.         ; OUT :    d0 = ULONG  old setup
  339.     ULONG    resload_ListFiles
  340.         ; list filenames of directory
  341.         ; IN :    d0 = ULONG  buffer size
  342.         ;    a0 = CSTR   name of directory to scan
  343.         ;    a1 = APTR   buffer (must be located in Slave)
  344.         ; OUT :    d0 = ULONG  amount of names in buffer
  345.         ;    d1 = ULONG  dos errorcode
  346.     ULONG    resload_Decrunch
  347.         ; uncompress data in memory
  348.         ; IN :    a0 = APTR   source
  349.         ;    a1 = APTR   destination (can be equal to source)
  350.         ; OUT :    d0 = ULONG  uncompressed size
  351.     ULONG    resload_LoadFileDecrunch
  352.         ; load file and uncompress
  353.         ; IN :    a0 = CSTR   filename
  354.         ;    a1 = APTR   address
  355.         ; OUT :    d0 = ULONG  success (size of file)
  356.         ;    d1 = ULONG  dos errorcode
  357.     ULONG    resload_FlushCache
  358.         ; clear CPU caches
  359.         ; IN :    -
  360.         ; OUT :    -
  361.     ULONG    resload_GetFileSize
  362.         ; get size of a file
  363.         ; IN :    a0 = CSTR   filename
  364.         ; OUT :    d0 = ULONG  size of file
  365.     ULONG    resload_DiskLoad
  366.         ; load part from diskimage
  367.         ; IN :    d0 = ULONG  offset
  368.         ;    d1 = ULONG  size
  369.         ;    d2 = ULONG  disk number
  370.         ;    a0 = APTR   destination
  371.         ; OUT :    d0 = BOOL   success
  372.         ;    d1 = ULONG  dos errorcode
  373.  
  374. ******* the following functions require ws_Version >= 2
  375.  
  376.     ULONG    resload_DiskLoadDev
  377.         ; IN :    d0 = ULONG  offset
  378.         ;    d1 = ULONG  size
  379.         ;    a0 = APTR   destination
  380.         ;    a1 = STRUCT taglist
  381.         ; OUT :    d0 = BOOL   success
  382.         ;    d1 = ULONG  trackdisk errorcode
  383.  
  384. ******* the following functions require ws_Version >= 3
  385.  
  386.     ULONG    resload_CRC16
  387.         ; calculate 16 bit CRC checksum
  388.         ; IN :    d0 = ULONG  size
  389.         ;    a0 = APTR   address
  390.         ; OUT :    d0 = UWORD  CRC checksum
  391.  
  392. ******* the following functions require ws_Version >= 5
  393.  
  394.     ULONG    resload_Control
  395.         ; IN :    a0 = STRUCT taglist
  396.         ; OUT :    d0 = BOOL   success
  397.     ULONG    resload_SaveFileOffset
  398.         ; write memory to file at offset
  399.         ; IN :    d0 = ULONG  size
  400.         ;    d1 = ULONG  offset
  401.         ;    a0 = CSTR   filename
  402.         ;    a1 = APTR   address
  403.         ; OUT :    d0 = BOOL   success
  404.         ;    d1 = ULONG  dos errcode
  405.  
  406. ******* the following functions require ws_Version >= 6
  407.  
  408.     ULONG    resload_ProtectRead
  409.         ; mark memory as read protected
  410.         ; IN :    d0 = ULONG  length
  411.         ;    a0 = APTR   address
  412.         ; OUT :    -
  413.     ULONG    resload_ProtectReadWrite
  414.         ; mark memory as read and write protected
  415.         ; IN :    d0 = ULONG  length
  416.         ;    a0 = APTR   address
  417.         ; OUT :    -
  418.     ULONG    resload_ProtectWrite
  419.         ; mark memory as write protected
  420.         ; IN :    d0 = ULONG  length
  421.         ;    a0 = APTR   address
  422.         ; OUT :    -
  423.     ULONG    resload_ProtectRemove
  424.         ; remove memory protection
  425.         ; IN :    d0 = ULONG  length
  426.         ;    a0 = APTR   address
  427.         ; OUT :    -
  428.     ULONG    resload_LoadFileOffset
  429.         ; load part of file to memory
  430.         ; IN :    d0 = ULONG  size
  431.         ;    d1 = ULONG  offset
  432.         ;    a0 = CSTR   name of file
  433.         ;    a1 = APTR   destination
  434.         ; OUT :    d0 = BOOL   success
  435.         ;    d1 = ULONG  dos errorcode
  436.  
  437. ******* the following functions require ws_Version >= 8
  438.  
  439.     ULONG    resload_Relocate
  440.         ; relocate AmigaDOS executable
  441.         ; IN :    a0 = APTR   address (source=destination)
  442.         ;    a1 = STRUCT taglist
  443.         ; OUT :    d0 = ULONG  size
  444.     ULONG    resload_Delay
  445.         ; wait some time
  446.         ; IN :    d0 = ULONG  time to wait in 1/10 seconds
  447.         ; OUT :    -
  448.     ULONG    resload_DeleteFile
  449.         ; delete file
  450.         ; IN :    a0 = CSTR   filename
  451.         ; OUT :    d0 = BOOL   success
  452.         ;    d1 = ULONG  dos errorcode
  453.  
  454. ******* the following functions require ws_Version >= 10
  455.  
  456.     ULONG    resload_ProtectSMC
  457.         ; detect self modifying code
  458.         ; IN :    d0 = ULONG  length
  459.         ;    a0 = APTR   address
  460.         ; OUT :    -
  461.     ULONG    resload_SetCPU
  462.         ; control CPU setup
  463.         ; IN :    d0 = ULONG  properties
  464.         ;    d1 = ULONG  mask
  465.         ; OUT :    d0 = ULONG  old properties
  466.     ULONG    resload_Patch
  467.         ; apply patchlist
  468.         ; IN :    a0 = APTR   patchlist
  469.         ;    a1 = APTR   destination address
  470.         ; OUT :    -
  471.  
  472. ******* the following functions require ws_Version >= 11
  473.  
  474.     ULONG    resload_LoadKick
  475.         ; load kickstart image
  476.         ; IN :    d0 = ULONG  length of image
  477.         ;    d1 = UWORD  crc16 of image
  478.         ;    a0 = CSTR   basename of image
  479.         ; OUT :    -
  480.     ULONG    resload_Delta
  481.         ; apply wdelta
  482.         ; IN :    a0 = APTR   src data
  483.         ;    a1 = APTR   dest data
  484.         ;    a2 = APTR   wdelta data
  485.         ; OUT :    -
  486.     ULONG    resload_GetFileSizeDec
  487.         ; get size of a packed file
  488.         ; IN :    a0 = CSTR   filename
  489.         ; OUT :    d0 = ULONG  size of file
  490.  
  491. ******* the following functions require ws_Version >= 15
  492.  
  493.     ULONG    resload_PatchSeg
  494.         ; apply patchlist to a segment list
  495.         ; IN :    a0 = APTR   patchlist
  496.         ;    a1 = BPTR   segment list
  497.         ; OUT :    -
  498.  
  499.     ULONG    resload_Examine
  500.         ; apply patchlist to a segment list
  501.         ; IN :    a0 = CSTR   name
  502.         ;    a1 = APTR   struct FileInfoBlock (260 bytes)
  503.         ; OUT :    d0 = BOOL   success
  504.         ;    d1 = ULONG  dos errorcode
  505.  
  506.     ULONG    resload_ExNext
  507.         ; apply patchlist to a segment list
  508.         ; IN :    a0 = APTR   struct FileInfoBlock (260 bytes)
  509.         ; OUT :    d0 = BOOL   success
  510.         ;    d1 = ULONG  dos errorcode
  511.  
  512.     ULONG    resload_GetCustom
  513.         ; get Custom argument
  514.         ; IN :    d0 = ULONG  length of buffer
  515.         ;    d1 = ULONG  reserved, must be 0
  516.         ;    a0 = APTR   buffer
  517.         ; OUT :    d0 = BOOL   true if Custom has fit into buffer
  518.  
  519.     LABEL    resload_SIZEOF
  520.  
  521. ******* compatibility for older slave sources:
  522.  
  523. resload_CheckFileExist = resload_GetFileSize
  524.  
  525. ;=============================================================================
  526. ; commands used in patchlist
  527. ; each command follows the address to modify, if bit 16 of the command is
  528. ; cleared address follows as 32 bit, if bit 16 of the command is set it
  529. ; follows as 16 bit (unsigned extended to 32 bit)
  530.  
  531.     ENUM    0
  532.     EITEM    PLCMD_END        ;end of list
  533.     EITEM    PLCMD_R            ;set "rts"
  534.     EITEM    PLCMD_P            ;set "jmp"
  535.     EITEM    PLCMD_PS        ;set "jsr"
  536.     EITEM    PLCMD_S            ;set "bra.w" (skip)
  537.     EITEM    PLCMD_I            ;set "illegal"
  538.     EITEM    PLCMD_B            ;write byte to specified address
  539.     EITEM    PLCMD_W            ;write word to specified address
  540.     EITEM    PLCMD_L            ;write long to specified address
  541. ; version 11
  542.     EITEM    PLCMD_A            ;write address which is calculated as
  543.                     ;base + arg to specified address
  544. ; version 14
  545.     EITEM    PLCMD_PA        ;write address given by argument to
  546.                     ;specified address
  547.     EITEM    PLCMD_NOP        ;fill given area with nop instructions
  548. ; version 15
  549.     EITEM    PLCMD_C            ;clear n bytes
  550.     EITEM    PLCMD_CB        ;clear one byte
  551.     EITEM    PLCMD_CW        ;clear one word
  552.     EITEM    PLCMD_CL        ;clear one long
  553. ; version 16
  554.     EITEM    PLCMD_PSS        ;set "jsr","nop..."
  555.     EITEM    PLCMD_NEXT        ;continue with another patch list
  556.     EITEM    PLCMD_AB        ;add byte to specified address
  557.     EITEM    PLCMD_AW        ;add word to specified address
  558.     EITEM    PLCMD_AL        ;add long to specified address
  559.     EITEM    PLCMD_DATA        ;write n data bytes to specified address
  560.  
  561. ;=============================================================================
  562. ; macros to build patchlist
  563.  
  564. PL_START    MACRO            ;start of patchlist
  565. .patchlist
  566.         ENDM
  567.  
  568. PL_END        MACRO            ;end of patchlist
  569.     dc.w    PLCMD_END
  570.         ENDM
  571.  
  572. PL_CMDADR    MACRO            ;set cmd and address
  573.     IFLT $ffff-\2
  574.     dc.w    \1
  575.     dc.l    \2
  576.     ELSE
  577.     dc.w    $8000+\1
  578.     dc.w    \2
  579.     ENDC
  580.     ENDM
  581.  
  582. PL_R        MACRO            ;set "rts"
  583.     PL_CMDADR PLCMD_R,\1
  584.         ENDM
  585.  
  586. PL_PS        MACRO            ;set "jsr"
  587.     PL_CMDADR PLCMD_PS,\1
  588.     dc.w    \2-.patchlist        ;destination (inside slave!)
  589.         ENDM
  590.  
  591. PL_P        MACRO            ;set "jmp"
  592.     PL_CMDADR PLCMD_P,\1
  593.     dc.w    \2-.patchlist        ;destination (inside slave!)
  594.         ENDM
  595.  
  596. PL_S        MACRO            ;skip bytes, set "bra"
  597.     PL_CMDADR PLCMD_S,\1
  598.     dc.w    \2-2            ;distance
  599.         ENDM
  600.  
  601. PL_I        MACRO            ;set "illegal"
  602.     PL_CMDADR PLCMD_I,\1
  603.         ENDM
  604.  
  605. PL_B        MACRO            ;write byte
  606.     PL_CMDADR PLCMD_B,\1
  607.     dc.w    \2            ;data to write
  608.         ENDM
  609.  
  610. PL_W        MACRO            ;write word
  611.     PL_CMDADR PLCMD_W,\1
  612.     dc.w    \2            ;data to write
  613.         ENDM
  614.  
  615. PL_L        MACRO            ;write long
  616.     PL_CMDADR PLCMD_L,\1
  617.     dc.l    \2            ;data to write
  618.         ENDM
  619.  
  620. ; version 11
  621.  
  622. PL_A        MACRO            ;write address (base+arg)
  623.     PL_CMDADR PLCMD_A,\1
  624.     dc.l    \2            ;data to write
  625.         ENDM
  626.  
  627. ; version 14
  628.  
  629. PL_PA        MACRO            ;write address
  630.     PL_CMDADR PLCMD_PA,\1
  631.     dc.w    \2-.patchlist        ;destination (inside slave!)
  632.         ENDM
  633.  
  634. PL_NOP        MACRO            ;fill area with nop's
  635.     PL_CMDADR PLCMD_NOP,\1
  636.     dc.w    \2            ;distance
  637.         ENDM
  638.  
  639. ; version 15
  640.  
  641. PL_C        MACRO            ;clear area
  642.     PL_CMDADR PLCMD_C,\1
  643.     dc.w    \2            ;length
  644.         ENDM
  645.  
  646. PL_CB        MACRO            ;clear one byte
  647.     PL_CMDADR PLCMD_CB,\1
  648.         ENDM
  649.  
  650. PL_CW        MACRO            ;clear one word
  651.     PL_CMDADR PLCMD_CW,\1
  652.         ENDM
  653.  
  654. PL_CL        MACRO            ;clear one long
  655.     PL_CMDADR PLCMD_CL,\1
  656.         ENDM
  657.  
  658. PL_PSS        MACRO            ;set "jsr","nop..."
  659.     PL_CMDADR PLCMD_PSS,\1
  660.     dc.w    \2-.patchlist        ;destination (inside slave!)
  661.     dc.w    \3            ;byte count of nop's to append
  662.         ENDM
  663.  
  664. PL_NEXT        MACRO            ;continue with another patch list
  665.     PL_CMDADR PLCMD_NEXT,0
  666.     dc.w    \1-.patchlist        ;destination (inside slave!)
  667.         ENDM
  668.  
  669. PL_AB        MACRO            ;add byte
  670.     PL_CMDADR PLCMD_AB,\1
  671.     dc.w    \2            ;data to add
  672.         ENDM
  673.  
  674. PL_AW        MACRO            ;add word
  675.     PL_CMDADR PLCMD_AW,\1
  676.     dc.w    \2            ;data to add
  677.         ENDM
  678.  
  679. PL_AL        MACRO            ;add long
  680.     PL_CMDADR PLCMD_AL,\1
  681.     dc.l    \2            ;data to add
  682.         ENDM
  683.  
  684. ; there are two macros provided for the DATA command, if you want change a 
  685. ; string PL_STR can be used:
  686. ;    PL_STR    $340,<NewString!>
  687. ; for binary data you must use PL_DATA like to follwing example:
  688. ;    PL_DATA    $350,.stop-.strt
  689. ; .strt    dc.b    2,3,$ff,'a',0
  690. ; .stop    EVEN
  691.  
  692. PL_DATA        MACRO            ;write n bytes to specified address
  693.     PL_CMDADR PLCMD_DATA,\1
  694.     dc.w    \2            ;count of bytes to write
  695.         ENDM
  696.  
  697. PL_STR        MACRO
  698.     PL_CMDADR PLCMD_DATA,\1
  699.     dc.w    .dat2\@-.dat1\@
  700. .dat1\@    dc.b    '\2'
  701. .dat2\@    EVEN
  702.         ENDM    
  703.  
  704. ;=============================================================================
  705.  
  706.  ENDC
  707.